package com.cxria.problem.conf


import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import springfox.documentation.builders.ApiInfoBuilder
import springfox.documentation.builders.PathSelectors
import springfox.documentation.builders.RequestHandlerSelectors
import springfox.documentation.service.ApiInfo
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.swagger2.annotations.EnableSwagger2

@Configuration
@EnableSwagger2
class SwaggerConf {

	@Bean
    Docket createRestApi() {
		new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
				.apis(RequestHandlerSelectors.basePackage('com.cxria.problem')).paths(PathSelectors.any()).build()
	}

    ApiInfo apiInfo() {
		String description = '''正常, 0000, send success &#10
用户没有登陆, 1001, user not login &#10
用户角色, 1002, user role error &#10
用户权限错误, 1003, user authority error &#10
账户和密码不匹配, 1004, user incorrect credentials error &#10
邮箱协议错误, 2001, mail protocol error &#10
邮箱账户或密码错误, 2002, mail password error &#10
数据已存在, 3001, data already exists error &#10
表格数据错误, 4001, xls data error &#10
不是xls文件错误, 4002, not is xls file error &#10
数据保存错误, 5001, data save error &#10
数据验证错误, 5002, data vidlation error &#10
预警反馈错误, 6001, msg feedback error &#10
没有找到手机号或备注时间错误, 7001, not find phone or bespeak time error &#10
未知错误, 9999, unkunwn error'''
		new ApiInfoBuilder().title('服务api').description(description.toString()).version('1.1').build()
	}

}